// 类模板与友元
#include <iostream>
#include <string>
using namespace std;
// 类外实现友元
template<class T1, class T2>
class Person;
template<class T1, class T2>
void show2(Person<T1, T2> &p)
{
    cout << "outer - name: " << p.m_name << "  age: " << p.m_age << endl;
}
template<class T1, class T2>
class Person
{
    // 类内实现友元
    friend void show1(Person<T1, T2> &p)
    {
        cout << "inner - name: " << p.m_name << "  age: " << p.m_age << endl;
    }
    // 加空模板参数列表
    friend void show2<>(Person<T1, T2> &p);
private:
    T1 m_name;
    T2 m_age;
public:
    Person(T1 name, T2 age);
};
template<class T1, class T2>
Person<T1, T2>::Person(T1 name, T2 age)
{
    this->m_name = name;
    this->m_age = age;
}
void test1()
{
    Person<string, int> p1("lxy", 20);
    show1(p1);
}
void test2()
{
    Person<string, int> p1("lxy", 20);
    show2(p1);
}
int main(void)
{
    test1();
    test2();
    
    return 0;
}